/* SPDX-License-Identifier: GPL-2.0 */

#ifndef DIM_CALCULATE_H
#define DIM_CALCULATE_H

#include "dim_hash.h"

/**
 * dim_calc_user_task_text_digest - calculate digest of a user task cod
 * segment
 * @mm: pointer to mm struct
 * @vma: pointer to a user task vma struct pointer
 * @hash_index: hash algorithm
 * @digest_out: output buffer (should be allocated before calling)
 *
 * Return: length of digest on success or errno on failure
 */
int dim_calc_user_task_text_digest(struct mm_struct *mm,
				   struct vm_area_struct *vma,
				   enum dim_hash_type hash_index,
				   char *digest_out);

/**
 * dim_calc_user_task_trampoline_digest - calculate digest of a user
 * trampoline section
 * @tsk: pointer to mm struct
 * @vma: pointer to a user task vma struct pointer
 * @hash_index: hash algorithm
 * @digest_out: output buffer (should be allocated before calling)
 *
 * Return: length of digest on success or errno on failure
 */
int dim_calc_user_task_trampoline_digest(struct mm_struct *mm,
					 struct vm_area_struct *vma,
					 enum dim_hash_type hash_index,
					 char *digest_out);

/**
 * dim_calc_kernel_digest - calculate digest of kernel code segment
 * @hash_index: hash algorithm
 * @digest_out: digest buffer (should be allocated before calling)
 *
 * Return: length of digest on success or errno on failure
 */
int dim_calc_kernel_digest(enum dim_hash_type hash_index, char *digest_out);


/**
 * dim_calc_ko_digest - calculate digest of ko code segment
 * @mod: pointer to ko struct
 * @hash_index: hash algorithm
 * @digest_out: digest buffer (should be allocated before calling)
 *
 * Return: length of digest on success or errno on failure
 */
int dim_calc_ko_digest(struct module *mod,
			enum dim_hash_type hash_index,
			char *digest_out);

#endif /* DIM_CALCULATE_H */
